<template>
    <div style="padding:20px">

      <div style="margin-bottom: 15px">
      <el-input
        v-model="queryParams.openId"
        placeholder="请输入openId"
        style="width: 200px"
        class="filter-item"
        @keyup.enter.native="queryBtn"
      />
      <el-input
        v-model="queryParams.parkfieldName"
        placeholder="请输入场站名称"
        style="width: 200px;margin-left:5px"
        class="filter-item"
        @keyup.enter.native="queryBtn"
      />
      <el-input
        v-model="queryParams.signName"
        placeholder="请输入打卡人员"
        style="width: 200px;margin-left:5px"
        class="filter-item"
        @keyup.enter.native="queryBtn"
      />
      <el-button
        class="filter-item"
        type="primary"
        icon="el-icon-search"
        style="margin-left: 5px"
        @click="queryBtn"
      >
        查询
      </el-button>
      <span style="float: right;
    margin-right: 20px;
    font-weight: 600;color: #494949;">当前账号：<span style="color: #ff770f;">{{title}}</span></span>
        </div>
   
    <el-row>
      <el-col :span="24">

        <el-table
      :header-cell-style="{ background: '#ffffff', color: '#000000' }"
      :key="tableKey"
      :row-class-name="tableRowClassName"
      v-loading="loading"
      :data="list"
      :stripe="true"
      border
      fit
      highlight-current-row
      style="
        width: 100%;
        font-size: 15px;
        box-shadow: 1px 1px 8px #cdcdcd;
        border: 0px;
      "
      @sort-change="sortChange"
    >
        <!-- <el-table ref="lcredepositrequestTable" v-loading="loading" :data="list" :stripe="true" :row-key="'id'" :max-height="clientHeight" :height="clientHeight" @selection-change="handleTableChange"> -->
          <el-table-column prop="openId" label="openId" width="180" sortable align="center">
          </el-table-column>
          <el-table-column prop="parkfieldName" label="场站名称" width="180" sortable align="center">
          </el-table-column>
              
          <el-table-column prop="signDate" label="打卡时间" width="" align="center">
          </el-table-column>
          <el-table-column prop="signName" label="打卡人员" width="" align="center">
          </el-table-column>
         
          <el-table-column prop="notes" label="备注" width="" align="center">
          </el-table-column>
          <el-table-column prop="issueDesc" label="问题描述" width="" align="center">
          </el-table-column>
          
            <el-table-column prop="livePic" label="图片" width="180" align="center">
              <template slot-scope="{ row }">
        <el-button type="primary" size="mini" @click="handleUpdate(row)">
           查看
         </el-button>
        </template>
            </el-table-column>
         
        </el-table>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24" class="page-tool">
        <el-pagination layout="total,sizes,prev, pager,next,jumper" :page-size="pageSize" :total="total" :page-sizes="[10, 20, 30, 40]" @size-change="handlePageChange" @current-change="handleNoChange">
        </el-pagination>
      </el-col>
    </el-row>


    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" center width="1590px">
    <el-form
      ref="dataForm"
      :rules="rules"
      :model="temp"
      label-position="left"
      label-width="70px"
    >
      <el-image 
          style="width:1536px;height:864px;"
          :src="url" 
          :preview-src-list="srcList">
          <div slot="error" class="image-slot" style="text-align:center">
              暂无图片
          </div>
      </el-image>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false"> 关闭 </el-button>
    </div>
  </el-dialog>

</div>
</template>
  
  <script>
   
  import { getNickName, getTestUserName,getRoleCode } from "../../utils/auth";
  import { inspectRecordApi } from "@/api/inspectRecord";
  
  export default {
    name: "oplog",
    data: function () {
      return {
        clientHeight:
          Math.max(
            document.documentElement.scrollHeight,
            document.body.scrollHeight
          ) -
          132 -
          5 +
          10 -
          28,
        labelWidth: "100px",
        loading: false,
        dialogTitle: "",
        pageNo: 1,
        pageSize:20,
        total: 0,
        multipleSelection: [],
        dialogFormVisible:false,
        dialogStatus: "",
        textMap: {
        update: "查看",
         create: "查看",
        },
        roleCode:'',
        queryParams:{
         openId:'',
         parkfieldName:'',
         signName:''
        },
        addDialog:false,
        parkfieldList: [],
        status: '',
  
      };
    },
    methods: {
      editBtn (index, row) {
        let _this = this;
        _this.$nextTick(()=>{
          if(_this.$refs.form != undefined){
            _this.$refs.form.resetFields();
          }
        });
        _this.feeForm = row;
        _this.addDialog = true;
      },
      
      
      procRefund (index, row, status) {
        let _this = this;
        _this.loading = true;
        procRefundApi(row.id, status).then(resp => {
          console.log(resp)
          _this.loadAbnormalOrder(this.pageNo, this.pageSize);
          _this.$notify({
                title: "成功",
                message: "已处理",
                type: "success"
              });
        });
      },
      handlePageChange (pageSize) {
        this.pageSize = pageSize;
        this.inspactRecord(this.pageNo, this.pageSize);
      },
      handleNoChange (pageNo) {
        this.pageNo = pageNo;
        this.inspactRecord(this.pageNo, this.pageSize);
      },
      handleTableChange (val) {
        this.multipleSelection = val;
      },
  
      
      inspactRecord(pageNo, pageSize) {
        let _this = this;
        _this.loading = true;
        inspectRecordApi( {
          pageNo:pageNo,
          pageSize:pageSize,
          signName:_this.queryParams.signName,
          openId:_this.queryParams.openId,
          parkfieldName:_this.queryParams.parkfieldName,
          roleCode:this.roleCode
        }).then(resp => {
            if (resp.errmsg === "ok") {
              console.log(resp.data.dataList);
              _this.total = resp.data.totalNum;
              _this.list = resp.data.dataList;
            }
            setTimeout(() => {
            _this.loading = false;
          }, 1 * 1000);
        });
      },
  
      handleUpdate(row) {
      this.url = '';
      this.temp = Object.assign({}, row); // copy obj
      this.temp.timestamp = new Date(this.temp.timestamp);
      this.dialogStatus = "查看";
      this.dialogFormVisible = true;
      
      this.url = row.livePic;
      console.log('1111111111111111111111111111111',this.url);
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
  
      queryBtn () {
        let _this = this;
        _this.loading = true;
        const data = {
          signName:_this.queryParams.signName,
          openId:_this.queryParams.openId,
          parkfieldName:_this.queryParams.parkfieldName,
          pageNo:_this.pageNo,
          pageSize:_this.pageSize,
          roleCode:this.roleCode
      };
      inspectRecordApi(data).then(resp => {
          _this.lcredepositrequests = resp.data;
          _this.total = resp.data.totalNum;
          _this.list = resp.data.dataList;
          _this.loading = false;
        });
      }
    },
    computed: {
      userState () {
        return getNickName() === getTestUserName();
      }
    },
    mounted: function () {
      let _this = this;
      _this.title = localStorage.getItem("title");
      _this.roleCode = localStorage.getItem("key");
      this.$nextTick(function () {
        this.inspactRecord(_this.pageNo, _this.pageSize);
      });
    }
  }
  </script>
  
  <style scoped>
  .page-tool {
    background: rgb(237, 231, 231);
  }
  
  .page-tool div {
    text-align: right;
  }
  
  .lock-btn {
    margin-bottom: 5px;
    margin-top: -10px;
  }
  .operateBtn {
    font-size: 18px;
    width: 32px;
    height: 32px;
    padding: 0;
  }
  </style>